package com.zt.bus.assistant.controller;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zt.bus.assistant.service.InstructionService;
import com.zt.servlet.ReqBean;
import com.zt.servlet.RequestAttribute;
import com.zt.servlet.Response;


@Controller
@RequestMapping(value = "/instruction")
public class InstructionController {

    @Autowired
    private InstructionService instructionService;

    /**
     * 查询
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/query")
    @ResponseBody
    public JSONObject queryNotice(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(instructionService.findInstruction(reqBean));
    }

    /**
     * 查询
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/query4Mobile")
    @ResponseBody
    public JSONObject query4Mobile(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(instructionService.query4Mobile(reqBean));
    }

    /**
     * 添加
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public JSONObject addNotice(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
    	instructionService.addInstruction(reqBean);
        return Response.responseSuccess();
    }

    /**
     * 修改
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public JSONObject updateNotice(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
    	instructionService.updateInstruction(reqBean);
        return Response.responseSuccess();
    }

    /**
     * 删除
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public JSONObject removeNotice(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
    	instructionService.removeInstruction(reqBean);
        return Response.responseSuccess();
    }

    //TODO 其他功能
}